﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using CoreAudioApi;
using SuntabuAssistant.AssistAchieve.Volume;

namespace SuntabuAssistant.AssistAchieve.Action
{
    public class Volume
    {
        private static MMDevice device;

        public const int MaxVolume = 100000;
        public Volume()
        {
           
        }


        public static void SetVolume(float value)
        {
            var devEnum = new MMDeviceEnumerator();
            device = devEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
            //tbMaster.Value = (int)(device.AudioEndpointVolume.MasterVolumeLevelScalar * 100);

            if (value < 0)
            {
                value = 0;
            }

            if (value > 100)
            {
                value = 100;
            }

            device.AudioEndpointVolume.MasterVolumeLevelScalar = value;
        }

        public static void SetMute()
        {
            SetVolume(0);
        }

     
    }
}
